package org.example;

import java.math.BigDecimal;
import java.time.LocalDate;

/**
 * 测试数据量计算
 */
public class TestDataVolumeCalculation {
    
    public static void main(String[] args) {
        // 配置参数
        LocalDate startDate = LocalDate.of(2023, 7, 1);
        LocalDate currentDate = LocalDate.now();
        int baseOrders = 300;
        int monthlyIncrease = 30;
        
        // 贷款金额范围
        int minLoanAmount = 300000; // 30万
        int maxLoanAmount = 700000; // 70万
        int avgLoanAmount = (minLoanAmount + maxLoanAmount) / 2; // 50万
        
        // 计算总订单数
        LocalDate month = startDate;
        int totalOrders = 0;
        int monthCount = 0;
        
        while (!month.isAfter(currentDate)) {
            int monthsFromStart = (int) (month.toEpochDay() - startDate.toEpochDay()) / 30;
            int monthlyOrders = baseOrders + (monthsFromStart * monthlyIncrease);
            totalOrders += monthlyOrders;
            monthCount++;
            
            System.out.println("月份: " + month + ", 订单数: " + monthlyOrders);
            
            month = month.plusMonths(1);
        }
        
        // 计算总金额
        BigDecimal totalLoanAmount = BigDecimal.valueOf(totalOrders).multiply(BigDecimal.valueOf(avgLoanAmount));
        
        System.out.println("\n=== 计算结果 ===");
        System.out.println("总月数: " + monthCount);
        System.out.println("总订单数: " + totalOrders);
        System.out.println("平均贷款金额: " + avgLoanAmount + " 元");
        System.out.println("总贷款金额: " + totalLoanAmount.divide(new BigDecimal("100000000"), 2, BigDecimal.ROUND_HALF_UP) + " 亿");
        
        // 估算在途余额（假设40%的订单未结清，平均剩余70%的金额）
        BigDecimal outstandingRate = new BigDecimal("0.4"); // 40%未结清
        BigDecimal remainingRate = new BigDecimal("0.7"); // 平均剩余70%
        BigDecimal estimatedOutstanding = totalLoanAmount.multiply(outstandingRate).multiply(remainingRate);
        
        System.out.println("估算在途余额: " + estimatedOutstanding.divide(new BigDecimal("100000000"), 2, BigDecimal.ROUND_HALF_UP) + " 亿");
    }
}
